(function(){
    let inputNumberEle = document.querySelector('.y-inputnumber');
    let minus = inputNumberEle.firstElementChild;
    let plus = inputNumberEle.lastElementChild;
    let numberVal = minus.nextElementSibling;
    let num = 1;
    //减一
    minus.addEventListener('click', function(){
        if(--num < 1){
            num = 1;
            this.style.disabled = true;
        }
        numberVal.value = num;
    })
    //加一
    plus.addEventListener('click', function(){
        num++;
        numberVal.value = num;
    })

    //改变输入框值
    numberVal.addEventListener('change',function(){
        if(isNaN(this.value)){
            alert('请输入数字');
        }else{
            num = this.value;
        }
    })
})()